package com.guigu.json;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.guigu.array.Student;

public class FastJsonTest {

	private Integer a;
	private BigDecimal b;
	private String c;
	private Boolean d;
	private List<Student> list;
	private Map<Integer, String> map;
	private Set<String> set;
	private Map<String, Set<String>> setMap;

	public Map<String, Set<String>> getSetMap() {
		return setMap;
	}

	public void setSetMap(Map<String, Set<String>> setMap) {
		this.setMap = setMap;
	}

	public Boolean getD() {
		return d;
	}

	public void setD(Boolean d) {
		this.d = d;
	}

	public String getC() {
		return c;
	}

	public void setC(String c) {
		this.c = c;
	}

	public Integer getA() {
		return a;
	}

	public void setA(Integer a) {
		this.a = a;
	}

	public BigDecimal getB() {
		return b;
	}

	public void setB(BigDecimal b) {
		this.b = b;
	}

	public List<Student> getList() {
		return list;
	}

	public void setList(List<Student> list) {
		this.list = list;
	}

	public Map<Integer, String> getMap() {
		return map;
	}

	public void setMap(Map<Integer, String> map) {
		this.map = map;
	}

	public Set<String> getSet() {
		return set;
	}

	public void setSet(Set<String> set) {
		this.set = set;
	}

	public static void main(String[] args) {
		FastJsonTest f = new FastJsonTest();
		Set<String> hashSet = new HashSet<>();
		Map<String, Set<String>> hashMap = new HashMap<>();
//		hashMap.put("key", null);
		hashMap.put("key", hashSet);
		f.setSetMap(hashMap);
		String json1 = JSON.toJSONString(f);
		String json2 = JSON.toJSONString(f, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty,
				SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero,
				SerializerFeature.WriteNullBooleanAsFalse);

		String json3 = JSON.toJSONString(f, SerializerFeature.WriteMapNullValue,
				SerializerFeature.WriteNullListAsEmpty);

		String json4 = JSON.toJSONString(f, SerializerFeature.WriteMapNullValue);
		String json5 = JSON.toJSONString(f, SerializerFeature.WriteNullListAsEmpty,
				SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero,
				SerializerFeature.WriteNullBooleanAsFalse);

		String json6 = JSON.toJSONString(f, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty,
				SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero,
				SerializerFeature.WriteNullBooleanAsFalse);
		System.out.println("json1===" + json1);
		System.out.println("json2===" + json2);
		System.out.println("json3===" + json3);
		System.out.println("json4===" + json4);
		System.out.println("json5===" + json5);
		System.err.println("json6===" + json6);
	}
}